package org.springcloud.wisdom.spring_02_classroom.admin.manageteacher.controller;

import org.springcloud.wisdom.spring_02_classroom.admin.manageteacher.service.ManageTeacherService;
import org.springcloud.wisdom.spring_02_classroom.bean.BaseController;
import org.springcloud.wisdom.spring_02_classroom.bean.ResponseData;
import org.springcloud.wisdom.spring_02_classroom.teacher.tschedule.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/teacher")
public class ManageTeacherController extends BaseController {
    @Autowired
    private ManageTeacherService manageTeacherService;

    // 修改教师密码
    @PutMapping("/pwd")
    public ResponseData<Object> updateTeacherPassword(@RequestBody Teacher teacher) {
        boolean success = manageTeacherService.updateTeacherPassword(teacher);
        return returnObject(success ? "修改成功！" : "修改失败！");
    }

    //基于课模糊查询教师编号和姓名的分页查看所有教师信息
    @RequestMapping("/all")
    public ResponseData<Object> getPage(@RequestParam("pageNum") int pageNum,
                                        @RequestParam("pageSize") int pageSize,
                                        @RequestParam(value = "tid",required = false) String tid,
                                        @RequestParam(value = "tname",required = false) String tname){
        return returnObject(manageTeacherService.AllTeacher(pageNum,pageSize,tid,tname));
    }
}
